<?php
class UserModel extends Model {

	public function getUserId(){
		$user = $this->getLoginUser();
		return $user['id'];
	}
	public function getLoginUser(){
		return (array)unserialize(Session::get('admin_user'));
	}
	public function doLogin($type=null,$pwd){
		if((is_null($type)||$user = $this->where($type)->find())&&!empty($user) && $vo['password'] = md5($pwd) && $user['status']>0){
			unset($user['password']);
			$user['expire'] = 60*10;
			$user['agent'] = md5($_SERVER['HTTP_USER_AGENT']);
			Session::set('admin_user',serialize($user));
			return true;
		}else{
			return false;
		}
	}
}